package com.jrx.anytxn.reporting.job.lsPuHui.step;

import com.jrx.anytxn.reporting.config.BreakContractConfig;
import com.jrx.anytxn.reporting.constant.ReportingConstant;
import com.jrx.anytxn.reporting.service.ILSPuHuiService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BreakContractWriter implements ItemWriter<String> {

    @Autowired
    private ILSPuHuiService linAnPuHuiService;
    @Autowired
    private BreakContractConfig breakContractConfig;


    @Override
    public void write(List<? extends String> items) throws Exception {
        if(CollectionUtils.isNotEmpty(items)){
            linAnPuHuiService.generateUnionFile((List<String>) items, breakContractConfig.getFilePath(),
                    breakContractConfig.getFileName(), ReportingConstant.LS_BREAK_CONTRACT);
        }
    }
}
